2026-09-20 · powershell, class-notes
Many people avoid PowerShell because they think it means "programming". But most day-to-day PowerShell is simply typing commands and pressing Enter, just as you would in CMD or Bash. A script is only a text file of…
Class notes · Learn PowerShell in a Month of Lunches (Jeffery Hicks et al.) · Chapter 4
Quick reference: the short version of this chapter is the Chapter 4 cheat sheet.
By the end of these notes you should be able to:
Many people avoid PowerShell because they think it means "programming". But most day-to-day PowerShell is simply typing commands and pressing Enter, just as you would in CMD or Bash. A script is only a text file of commands you've already learned to run interactively.
That's why the book spends so long at the prompt before it reaches scripting: if you can run a command, you can later automate it.
Get-ChildItem -Path C:\Logs -Filter *.log -Recurse \___________/ \___/ \_____/ \_____/ \___/ \______/ command name value name value switch \___________/ \____________/ parameter parameter
Part
Rules
Command name
Usually a cmdlet in Verb-Noun form. Not case-sensitive
Parameter name
Always begins with a dash: -Path
Value
Follows the parameter name after a space. Use quotes if it contains spaces: -Path "C:\My Files"
Switch
A parameter with no value. Its presence turns it on: -Recurse
Multiple values
Separate with commas: -Name notepad, calc
Note: a space goes between the parameter name and its value (-Path C:\Logs), and there's no space inside the name. - Path and -Path:C:\Logs are common beginner confusions. (The colon form is legal but rarely needed; stick to a space.)
Cmdlets (pronounced "command-lets") are PowerShell's native commands. They're named Verb-Noun:
Microsoft publishes a list of approved verbs, so the same verb means the same thing everywhere:
Get-Verb \
Get-Verb -Verb Stop \
Verb
Means
Example
Get
Retrieve information; changes nothing
Get-Process
Set
Change something that exists
Set-Location
New
Create something
New-Item
Remove
Delete something
Remove-Item
Start / Stop
Begin / end an operation or process
Start-Service
Because naming is consistent, you can often guess a command before looking it up.
You want to
Guess
Check
See the running services
Get-Service
Get-Command Get-Service (Windows)
Create a folder
New-Item
help New-Item -Examples
Delete a file
Remove-Item
Remove-Item -Path x.txt -WhatIf
See your current location
Get-Location
Run it
List every command for "Item"
—
Get-Command -Noun Item
Get verbs are safe to explore — they only read. The other verbs change things, so read their help first.
Get-Command reports a CommandType:
Type
What it is
Example
Cmdlet
Compiled .NET command built into PowerShell or a module
Get-ChildItem
Function
A command written in PowerShell itself
help is a function
Alias
A nickname for another command
gci → Get-ChildItem
Application
An external program (an .exe or native binary)
ping, ipconfig, ssh
Get-Command Get-ChildItem, help, gci | Select-Object Name, CommandType
An alias is a short or familiar name for a command. Many exist to make CMD and Bash users feel at home:
Alias
Runs
Familiar from
dir, gci
Get-ChildItem
CMD, PowerShell shorthand
cd
Set-Location
CMD and Bash
cls
Clear-Host
CMD
gps
Get-Process
PowerShell shorthand
ls, cat, ps
Get-ChildItem, Get-Content, Get-Process
Bash — Windows only (see 5.3)
Get-Alias gci \
Get-Alias -Definition Get-ChildItem \
New-Alias -Name np -Value notepad \
On Linux and macOS, PowerShell 7 doesn't define aliases that clash with real native commands: ls, cat, ps, cp, mv, rm, man and others.
Typed on Linux
What runs
ls
The native Linux ls — text output, Linux options like -la
Get-ChildItem or gci
The PowerShell cmdlet — objects
dir
Still an alias for Get-ChildItem
This trips people up when moving scripts between systems.
Caution: in scripts and anything you share, use full command names. Aliases save typing at the prompt but make scripts harder to read — and, as above, they don't behave the same on every platform.
You only need to type enough of a parameter name to make it unique for that command:
Get-ChildItem -Pa C:\Logs -Fi *.log \
Parameter cannot be processed because the parameter name 'F' is ambiguous. Possible matches include: -Filter -Force.
Some parameters have alternative names. Get-Process -Id also answers to -PID. Find them in help (the Aliases field) or with:
(Get-Command Get-Process).Parameters['Id'].Aliases \
Positional parameters can be given without their names, in order (chapter 3):
Get-ChildItem C:\Logs *.log \
Stage
Command
Full, as you'd write in a script
Get-ChildItem -Path C:\Logs -Filter *.log -Recurse
Alias for the command
gci -Path C:\Logs -Filter *.log -Recurse
Positional parameters
gci C:\Logs *.log -Recurse
Truncated switch
gci C:\Logs *.log -r
The last line is quick to type but hard to read. Rule of thumb: use shortcuts at the prompt; write the full form in scripts, documentation, tickets and your blog.
PowerShell runs ordinary programs too:
ping 8.8.8.8 ipconfig /all ssh andrew@server01
Key differences from cmdlets:
icacls C:\Data --% /grant Users:(OI)(CI)
R
PowerShell's error messages are usually specific and helpful — the red text is information, not a failure. Read the first line carefully.
Error message (first line)
Cause
Fix
The term 'Get-Proces' is not recognized as a name of a cmdlet, function, script file, or executable program.
Typo in the command name, or the command doesn't exist here
Use Tab completion; check with Get-Command
A parameter cannot be found that matches parameter name 'Nme'.
Misspelled or non-existent parameter
Check the syntax with Get-Command
Parameter cannot be processed because the parameter name 'F' is ambiguous.
Truncated name matches more than one parameter
Type more of the name
Cannot find path '/nope' because it does not exist.
Wrong path
Check spelling, case (on Linux) and current location
Cannot process command because of one or more missing mandatory parameters: Id.
A required value was left out
Supply it — interactively, PowerShell prompts you for it
If you run a command without a mandatory parameter in an interactive session, PowerShell prompts for the value rather than failing:
PS> Stop-Process cmdlet Stop-Process at command pipeline position 1 Supply values for the following parameters: Id[0]:Id[0] means it's asking for the first value of an array. Press Enter on an empty line to finish, or Ctrl+C to cancel.
Execution policy controls whether PowerShell will run script files (.ps1). It doesn't affect typing commands at the prompt.
Policy
Allows
Restricted
No scripts at all — the default on Windows client editions
AllSigned
Only scripts signed by a trusted publisher
RemoteSigned
Local scripts run; scripts downloaded from the internet must be signed. The default on Windows Server
Unrestricted
All scripts run; downloaded scripts trigger a warning
Bypass
Nothing is blocked and nothing warns
Get-ExecutionPolicy Get-ExecutionPolicy -List \
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
On Linux and macOS, execution policy isn't enforced: Get-ExecutionPolicy returns Unrestricted, and it can't be changed.
Microsoft is explicit that execution policy is not a security boundary. It's a safety feature to stop users running scripts by accident. Anyone can bypass it — by starting PowerShell with -ExecutionPolicy Bypass, or by pasting a script's contents into the console. Real protection comes from application control (such as AppLocker or WDAC), logging and least privilege.
Term
Definition
Cmdlet
A compiled PowerShell command named Verb-Noun
Parameter
A named input to a command, written with a leading dash
Value
The data given to a parameter
Switch parameter
A parameter with no value, turned on by its presence
Verb-Noun
The naming convention for PowerShell commands
Approved verbs
Microsoft's standard list of verbs, shown by Get-Verb
Noun prefix
A module-specific prefix on a noun, e.g. AD in Get-ADUser
CommandType
Cmdlet, Function, Alias or Application
Alias
A nickname for a command
Parameter alias
An alternative name for a parameter, e.g. -PID for -Id
Truncated parameter
A shortened parameter name that is still unique
Positional parameter
A parameter whose name can be omitted
External command / application
A program outside PowerShell, such as ping
Stop-parsing token (--%)
Tells PowerShell to pass the rest of the line unchanged
Mandatory parameter prompt
PowerShell asking for a required value that was omitted
Execution policy
A setting controlling whether script files may run
RemoteSigned
Policy requiring downloaded scripts to be signed
Profile
A script that runs when PowerShell starts, used to keep aliases and settings